<?php namespace lfy;

\lfy\setconst('LFY_LEAF_TEMPLATE', '\lfy\template\html');

class leaf extends schematic_ro{

	protected $template = LFY_LEAF_TEMPLATE;

	protected $properties = array();

	function property(){
	
		foreach(func_get_args() as $k){
	
			if(isset($this->properties[$k])) 
				return $this->properties[$k];
			
			$f = "get_property_$k";
			if(method_exists($this, $f)) 
				return $this->$f();

			$v = getenv('LFY_LEAF_PROPERTY_'.strtoupper($k));
			if(!is_null($v))
				return $v;
		}
		
	}
	
	function set_property($k, $v){
		$this->properties[$k] = $v;
	}

	function process(){}

	function run_template($mode = null, $cache = null){
		$template = $this->template;
		return $template::run($this, $mode, $cache);
	}
	
	function set_template($template){
		$this->template = $template;
	}

}